package com.xu.controller;

import com.xu.pojo.Orders;
import com.xu.service.center.MyOrderService;
import com.xu.utils.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;

/**
 * @author anan
 * @create 2022-02-22 0:14
 */
public class BaseController {
    @Autowired
    private MyOrderService myOrderService;


    public int cnt = 0;
    public static final String FOODIE_SHOPCART = "shopcart";
    public static final Integer COMMEN_PAGE_SIZE = 10;
    public static final Integer PAGE_SIZE = 20;



    // 微信支付成功 -> 支付中心 ->天天吃货平台
    String payReturnUrl = "http://api.peiqili.top/foodie-api/orders/notifyMerchantOrderPaid";
    String paymentUrl = "http://payment.t.mukewang.com/foodie-payment/payment/createMerchantOrder";

    // 用户头像保存的地址
    public static final String IMAGE_USER_FACE_LOCATION = "image" + File.separator + "faces";

    /**
     * 用于验证用户和订单是否有关联关系，避免非法用户调用
     */
    public JSONResult checkUserOrder(String userId, String orderId){
        Orders order = myOrderService.queryMyOrder(userId, orderId);
        if(order == null) return JSONResult.errorMsg("订单不存在！");
        return JSONResult.ok(order);
    }

}
